package core.ui.demo;

import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;

/**
 * @author 李瑜
 * @since JavaFX 8.0
 */
public class DemoBarChart
{
	@SuppressWarnings("unchecked")
	public static BarChart<String, Number> getBarChart()
	{

		CategoryAxis xAxis = new CategoryAxis();
		NumberAxis yAxis = new NumberAxis();
		BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis);

		barChart.setTitle("11级Java出勤率");

		xAxis.setLabel("月份");
		yAxis.setLabel("出勤率");

		XYChart.Series<String, Number> series1 = new XYChart.Series<String, Number>();
		series1.setName("3");
		series1.getData().add(new XYChart.Data<String, Number>("Java1", 65));
		series1.getData().add(new XYChart.Data<String, Number>("Java2", 60));
		series1.getData().add(new XYChart.Data<String, Number>("Java3", 75));
		series1.getData().add(new XYChart.Data<String, Number>("Java4", 80));

		XYChart.Series<String, Number> series2 = new XYChart.Series<String, Number>();
		series2.setName("4");
		series2.getData().add(new XYChart.Data<String, Number>("Java1", 70));
		series2.getData().add(new XYChart.Data<String, Number>("Java2", 80));
		series2.getData().add(new XYChart.Data<String, Number>("Java3", 70));
		series2.getData().add(new XYChart.Data<String, Number>("Java4", 75));

		XYChart.Series<String, Number> series3 = new XYChart.Series<String, Number>();
		series3.setName("5");
		series3.getData().add(new XYChart.Data<String, Number>("Java1", 60));
		series3.getData().add(new XYChart.Data<String, Number>("Java2", 70));
		series3.getData().add(new XYChart.Data<String, Number>("Java3", 65));
		series3.getData().add(new XYChart.Data<String, Number>("Java4", 85));

		barChart.getData().addAll(series1, series2, series3);
		return barChart;
	}
}
